﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:scm="clr-namespace:System.ComponentModel;assembly=WindowsBase"
             xmlns:local="clr-namespace:SuplexApp"
    xmlns:cc="clr-namespace:SuplexApp.Controls"
             xmlns:splx="clr-namespace:Suplex.Wpf;assembly=Suplex.Wpf"
             xmlns:splxApi="clr-namespace:Suplex.Forms.ObjectModel.Api;assembly=Suplex.Core"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:s="clr-namespace:System;assembly=mscorlib"
    xmlns:wpfc="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Classic"
    >

    <local:FormattingConverter x:Key="formatter" />

    <local:SecurityPrincipalDataTemplateSelector x:Key="SecurityPrincipalTemplateSelector"/>
    <local:SecurityPrincipalTypeConverter x:Key="securityPrincipalTypeConverter" />
    <local:SecurityPrincipalSourceConverter x:Key="securityPrincipalSourceConverter" />

    <DataTemplate DataType="{x:Type splxApi:SecurityPrincipalBase}" x:Key="securityPrincipalNameIconTemplate">
        <StackPanel Orientation="Horizontal">
            <Image Margin="0,0,4,0" Height="16" Width="16">
                <Image.Source>
                    <MultiBinding Converter="{StaticResource securityPrincipalTypeConverter}"
                                      ConverterParameter="/SuplexAdmin;component/Resources/Security/,user-16x16.png,user-16x16_disabled.png,users-16x16.png,users-16x16_disabled.png,users-16x16_ext.png,users-16x16_ext_disabled.png">
                        <Binding Path="IsUserObject" />
                        <Binding Path="IsLocal" />
                        <Binding Path="IsEnabled" />
                    </MultiBinding>
                </Image.Source>
            </Image>
            <TextBlock Text="{Binding Path=Name}" Foreground="{local:FormattedBinding Path=IsEnabled, ValueIfTrue=Black, ValueIfFalse=Gray}" VerticalAlignment="Center"/>
        </StackPanel>
    </DataTemplate>

    <DataTemplate DataType="{x:Type splxApi:SecurityPrincipalBase}" x:Key="securityPrincipalDescriptionTemplate">
        <TextBlock Text="{Binding Path=Description}" Foreground="{local:FormattedBinding Path=IsEnabled, ValueIfTrue=Black, ValueIfFalse=Gray}" VerticalAlignment="Center"/>
    </DataTemplate>

    <DataTemplate x:Key="RightRoleRule">
        <Label Content="{Binding Path=Name}"/>
    </DataTemplate>
    <DataTemplate x:Key="rightBindingRule">
        <StackPanel Grid.Column="0" Orientation="Horizontal">
            <Image Source="/SuplexAdmin;component/Resources/tree_vr.png" Margin="0,0,4,0"/>
            <Image Source="/SuplexAdmin;component/Resources/overlay_x.png" Margin="-26,0,0,0"
                                   Visibility="{local:FormattedBinding Path=FailParent, ValueIfTrue=Visible, ValueIfFalse=Hidden}"/>
            <TextBlock Text="{local:FormattedBinding Path=Name, FormatString='\{0\}'}" VerticalAlignment="Center" ToolTip="Name"/>
        </StackPanel>
    </DataTemplate>
    <DataTemplate x:Key="elseBindingRule">
        <StackPanel Grid.Column="0" Orientation="Horizontal">
            <Image Source="/SuplexAdmin;component/Resources/tree_er.png" Margin="0,0,4,0"/>
            <Image Source="/SuplexAdmin;component/Resources/overlay_x.png" Margin="-26,0,0,0"
                                   Visibility="{local:FormattedBinding Path=FailParent, ValueIfTrue=Visible, ValueIfFalse=Hidden}"/>
            <TextBlock Text="{local:FormattedBinding Path=Name, FormatString='\{0\}'}" VerticalAlignment="Center" ToolTip="Name"/>
        </StackPanel>
    </DataTemplate>
    <DataTemplate x:Key="successRightBinding">
        <StackPanel Orientation="Horizontal">
            <Image Source="/SuplexAdmin;component/Resources/10pxGreenDot.png"
                       HorizontalAlignment="Left" VerticalAlignment="Center" Height="10" Width="10" Margin="0,0,4,0"/>
            <TextBlock Text="{local:FormattedBinding Path=AceType, FormatString='\{0\}\\'}"/>
            <TextBlock Text="{local:FormattedBinding Path=RightName, FormatString='\{0\}'}"/>
        </StackPanel>
    </DataTemplate>
    <DataTemplate x:Key="elseRightBinding">
        <StackPanel Orientation="Horizontal">
            <Image Source="/SuplexAdmin;component/Resources/10pxBlueDot.png"
                       HorizontalAlignment="Left" VerticalAlignment="Center" Height="10" Width="10" Margin="0,0,4,0"/>
            <TextBlock Text="{local:FormattedBinding Path=AceType, FormatString='\{0\}\\'}"/>
            <TextBlock Text="{local:FormattedBinding Path=RightName, FormatString='\{0\}'}"/>
        </StackPanel>
    </DataTemplate>

    <SolidColorBrush x:Key="GlyphBrush" Color="#FF527DB5"/>
    <SolidColorBrush x:Key="TabControlNormalBorderBrush" Color="#8C8E94"/>

    <Style x:Key="DialogLabel" TargetType="{x:Type Label}">
        <Setter Property="VerticalAlignment" Value="Center"/>
        <Setter Property="HorizontalAlignment" Value="Right"/>
        <Setter Property="Padding" Value="0" />
        <Setter Property="Margin" Value="10,0,5,5"/>
    </Style>

    <Style x:Key="DialogTextBox" TargetType="{x:Type TextBox}">
        <Setter Property="Margin" Value="0,0,0,5"/>
    </Style>

    <Style x:Key="DialogControl" TargetType="{x:Type Control}">
        <Setter Property="Margin" Value="0,0,0,5"/>
    </Style>

    <Style x:Key="DialogStackPanel" TargetType="{x:Type StackPanel}">
        <Setter Property="Margin" Value="0,0,0,5"/>
    </Style>

    <Style x:Key="TabControlNoHeaderRow" TargetType="{x:Type TabControl}">
        <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
        <Setter Property="Padding" Value="4,4,4,4"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="BorderBrush" Value="{StaticResource TabControlNormalBorderBrush}"/>
        <Setter Property="Background" Value="#F9F9F9"/>
        <Setter Property="HorizontalContentAlignment" Value="Center"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TabControl}">
                    <Grid ClipToBounds="true" SnapsToDevicePixels="true" KeyboardNavigation.TabNavigation="Local">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition x:Name="ColumnDefinition0"/>
                            <ColumnDefinition x:Name="ColumnDefinition1" Width="0"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition x:Name="RowDefinition0" Height="Auto"/>
                            <RowDefinition x:Name="RowDefinition1" Height="*"/>
                        </Grid.RowDefinitions>
                        <TabPanel x:Name="HeaderPanel" Margin="2,-5,2,0" IsItemsHost="true" Panel.ZIndex="1" Grid.Column="0" Grid.Row="0" KeyboardNavigation.TabIndex="1"/>
                        <Border x:Name="ContentPanel" Grid.Column="0" Grid.Row="1" KeyboardNavigation.DirectionalNavigation="Contained" KeyboardNavigation.TabIndex="2" KeyboardNavigation.TabNavigation="Local" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
                            <ContentPresenter x:Name="PART_SelectedContentHost" Margin="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" ContentSource="SelectedContent"/>
                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="TabStripPlacement" Value="Bottom">
                            <Setter Property="Grid.Row" TargetName="HeaderPanel" Value="1"/>
                            <Setter Property="Grid.Row" TargetName="ContentPanel" Value="0"/>
                            <Setter Property="Height" TargetName="RowDefinition0" Value="*"/>
                            <Setter Property="Height" TargetName="RowDefinition1" Value="Auto"/>
                            <Setter Property="Margin" TargetName="HeaderPanel" Value="2,0,2,2"/>
                        </Trigger>
                        <Trigger Property="TabStripPlacement" Value="Left">
                            <Setter Property="Grid.Row" TargetName="HeaderPanel" Value="0"/>
                            <Setter Property="Grid.Row" TargetName="ContentPanel" Value="0"/>
                            <Setter Property="Grid.Column" TargetName="HeaderPanel" Value="0"/>
                            <Setter Property="Grid.Column" TargetName="ContentPanel" Value="1"/>
                            <Setter Property="Width" TargetName="ColumnDefinition0" Value="Auto"/>
                            <Setter Property="Width" TargetName="ColumnDefinition1" Value="*"/>
                            <Setter Property="Height" TargetName="RowDefinition0" Value="*"/>
                            <Setter Property="Height" TargetName="RowDefinition1" Value="0"/>
                            <Setter Property="Margin" TargetName="HeaderPanel" Value="2,2,0,2"/>
                        </Trigger>
                        <Trigger Property="TabStripPlacement" Value="Right">
                            <Setter Property="Grid.Row" TargetName="HeaderPanel" Value="0"/>
                            <Setter Property="Grid.Row" TargetName="ContentPanel" Value="0"/>
                            <Setter Property="Grid.Column" TargetName="HeaderPanel" Value="1"/>
                            <Setter Property="Grid.Column" TargetName="ContentPanel" Value="0"/>
                            <Setter Property="Width" TargetName="ColumnDefinition0" Value="*"/>
                            <Setter Property="Width" TargetName="ColumnDefinition1" Value="Auto"/>
                            <Setter Property="Height" TargetName="RowDefinition0" Value="*"/>
                            <Setter Property="Height" TargetName="RowDefinition1" Value="0"/>
                            <Setter Property="Margin" TargetName="HeaderPanel" Value="0,2,2,2"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>


    <!-- **************************************************************************************************************************************************** -->
    <!-- SplitButton Styles ********************************************************************************************************************************* -->
    <!-- **************************************************************************************************************************************************** -->

    <!-- Used for Checkmark, Radio button, TreeViewItem, Expander ToggleButton glyphs -->
    <!--<SolidColorBrush x:Key="GlyphBrush" Color="#444"/>-->

    <!-- SelectedBackgroundBrush is used for the Selected item in ListBoxItem, ComboBoxItem-->
    <SolidColorBrush x:Key="SelectedBackgroundBrush" Color="#DDD"/>

    <!-- Disabled Brushes are used for the Disabled look of each control -->
    <!--<SolidColorBrush x:Key="DisabledForegroundBrush" Color="#888"/>-->

    <!-- NormalBrush is used as the Background for SimpleButton, SimpleRepeatButton -->
    <!--<LinearGradientBrush x:Key="NormalBrush" EndPoint="0,1" StartPoint="0,0">
        <GradientStop Color="#EEE" Offset="0.0"/>
        <GradientStop Color="#CCC" Offset="1.0"/>
    </LinearGradientBrush>
    <LinearGradientBrush x:Key="NormalBorderBrush" EndPoint="0,1" StartPoint="0,0">
        <GradientStop Color="#CCC" Offset="0.0"/>
        <GradientStop Color="#444" Offset="1.0"/>
    </LinearGradientBrush>-->

    <Style x:Key="ButtonFocusVisual">
        <Setter Property="Control.Template">
            <Setter.Value>
                <ControlTemplate>
                    <Rectangle SnapsToDevicePixels="true" Margin="3" Stroke="Black" StrokeDashArray="1 2" StrokeThickness="1"/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <LinearGradientBrush x:Key="ButtonNormalBackgroundFill" EndPoint="0.5,1" StartPoint="0.5,0">
        <GradientStop Color="#FFFFFFFF" Offset="0"/>
        <GradientStop Color="#FFF0F0EA" Offset="0.9"/>
    </LinearGradientBrush>

    <SolidColorBrush x:Key="ButtonBorder" Color="#FF003C74"/>

    <Style x:Key="MainButtonStyle" TargetType="{x:Type Button}" BasedOn="{x:Null}">
        <Setter Property="Margin" Value="-2,-2,0,-2" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <Grid>
                        <Rectangle x:Name="rect" Fill="Transparent" Stroke="#00000000" Margin="5" />
                        <ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" RecognizesAccessKey="True"/>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsFocused" Value="True"/>
                        <Trigger Property="IsDefaulted" Value="True"/>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Fill" TargetName="rect" Value="#00FFFFFF"/>
                        </Trigger>
                        <Trigger Property="IsPressed" Value="True">
                            <Setter Property="Fill" TargetName="rect" Value="{DynamicResource PressedBrush}"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False"/>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type cc:SplitButton}">
        <Setter Property="FocusVisualStyle" Value="{StaticResource ButtonFocusVisual}"/>
        <Setter Property="BorderBrush" Value="{StaticResource ButtonBorder}"/>
        <Setter Property="Foreground" Value="#FF042271" />
        <Setter Property="HorizontalAlignment" Value="Center"/>
        <Setter Property="VerticalAlignment" Value="Stretch"/>
        <Setter Property="MinHeight" Value="20" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type cc:SplitButton}">
                    <Border SnapsToDevicePixels="True" CornerRadius="2"
                            Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}">
                        <Grid x:Name="Grid">
                            <Border x:Name="BackgroundNorm" BorderThickness="1" CornerRadius="1.75" Background="{DynamicResource NormalBrush}" BorderBrush="{DynamicResource NormalBorderBrush}"/>
                            <Border x:Name="BackgroundNorm_highlight" Margin="1" BorderBrush="{DynamicResource NormalHighlightBrush}" BorderThickness="1,0,1,1" CornerRadius="1" Opacity="0.65" />
                            <Border x:Name="BackgroundOver" BorderThickness="1" CornerRadius="1.75" Opacity="0" Background="{DynamicResource MouseOverBrush}" BorderBrush="{DynamicResource MouseOverBorderBrush}"/>
                            <Border x:Name="BackgroundOver_Highlight" Margin="1" BorderThickness="1,0,1,1" CornerRadius="1" Opacity="0" BorderBrush="{DynamicResource MouseOverHighlightBrush}"/>
                            <Border x:Name="BackgroundPressed" BorderThickness="1" CornerRadius="1.75" Opacity="0" Background="{DynamicResource PressedBrush}" BorderBrush="{DynamicResource PressedBorderBrush}"/>
                            <Border x:Name="BackgoundPressed_Highlight" Margin="1" BorderThickness="1,0,1,1" CornerRadius="1" Opacity="0" BorderBrush="{DynamicResource PressedHighlightBrush}"/>
                            <Border x:Name="DisabledVisualElement" IsHitTestVisible="false" Background="{DynamicResource DisabledBackgroundBrush}" BorderBrush="{DynamicResource DisabledBorderBrush}" BorderThickness="1" Opacity="0" />

                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition Width="14"/>
                                </Grid.ColumnDefinitions>
                                <Button x:Name="PART_Button" Grid.Column="0" Style="{DynamicResource MainButtonStyle}">
                                    <StackPanel Orientation="Horizontal">
                                        <!--<Image x:Name="icon" Margin="4,0,2,0" VerticalAlignment="Center" Width="16" Height="16" Source="{TemplateBinding Image}" />-->
                                        <Label Content="{TemplateBinding Text}" Target="{TemplateBinding Target}" VerticalAlignment="Center" Padding="0" Margin="0" Foreground="{TemplateBinding Foreground}"/>
                                    </StackPanel>
                                </Button>
                                <Border x:Name="line" Grid.Column="1" Visibility="Visible" BorderThickness="1,0,0,0" BorderBrush="#3F6C96" Margin="0,4,0,4"/>
                                <Border x:Name="lineGrey" Grid.Column="2" Visibility="Hidden" BorderThickness="1,0,0,0" BorderBrush="#B9CADA" Margin="0,4,0,4"/>
                                <Border Grid.Column="3" HorizontalAlignment="Center">
                                    <Path Fill="#FF042271" Data="M 0 0 L 4 4 L 8 0 Z" Height="5" Margin="-2.5,2,0,0"/>
                                </Border>
                            </Grid>

                            <TextBlock Panel.ZIndex="1" x:Name="DisabledOverlay" Text="{TemplateBinding Content}" Foreground="#FF8E96A2" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Margin="{TemplateBinding Padding}" Visibility="Collapsed" />
                            <Border x:Name="FocusVisualElement" Margin="-1" BorderBrush="{DynamicResource FocusBrush}" BorderThickness="1" CornerRadius="2.75" IsHitTestVisible="false" Opacity="0" />
                            <Border x:Name="DefaultBorder" Margin="-1" BorderBrush="{DynamicResource FocusBrush}" BorderThickness="1" CornerRadius="2.75" IsHitTestVisible="false" Opacity="0" />
                        </Grid>
                    </Border>

                    <ControlTemplate.Triggers>
                        <Trigger Property="ToggleButton.IsChecked" Value="True">
                            <Setter Property="Visibility" Value="Hidden" TargetName="line"/>
                            <!--<Setter Property="Visibility" Value="Hidden" TargetName="lineGrey"/>-->
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                            <Setter Property="Visibility" Value="Hidden" TargetName="line"/>
                            <!--<Setter Property="Visibility" Value="Hidden" TargetName="lineGrey"/>-->
                        </Trigger>
                        <Trigger Property="IsChecked" Value="True">
                            <Setter Property="BorderBrush" Value="#FF316AC5"/>
                            <Setter Property="Background" Value="#FFE1E6E8"/>
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="BorderBrush" Value="#FF316AC5"/>
                            <Setter Property="Background" Value="#FF99CCFF"/>
                            <Setter Property="Visibility" Value="Visible" TargetName="line"/>
                        </Trigger>
                        <Trigger Property="IsKeyboardFocused" Value="True">
                            <Setter Property="BorderBrush" Value="#FF316AC5"/>
                            <Setter Property="Background" Value="#FFC1D2EE"/>
                            <Setter Property="Visibility" Value="Visible" TargetName="line"/>
                        </Trigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsMouseOver" Value="True"/>
                                <Condition Property="IsChecked" Value="True"/>
                            </MultiTrigger.Conditions>
                            <Setter Property="BorderBrush" Value="#FF4B4B6F"/>
                            <Setter Property="Background" Value="#FF98B5E2"/>
                            <Setter Property="Visibility" Value="Visible" TargetName="line"/>
                        </MultiTrigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsKeyboardFocused" Value="True"/>
                                <Condition Property="IsChecked" Value="True"/>
                            </MultiTrigger.Conditions>
                            <Setter Property="BorderBrush" Value="#FF4B4B6F"/>
                            <Setter Property="Background" Value="#FF98B5E2"/>
                            <Setter Property="Visibility" Value="Visible" TargetName="line"/>
                        </MultiTrigger>
                        <Trigger Property="IsPressed" Value="True">
                            <Setter Property="BorderBrush" Value="#FF4B4B6F"/>
                            <Setter Property="Background" Value="#FF98B5E2"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="ButtonStyle" TargetType="{x:Type Button}">
        <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
        <Setter Property="Background" Value="#00FFFFFF"/>
        <Setter Property="HorizontalAlignment" Value="Stretch"/>
        <Setter Property="VerticalAlignment" Value="Stretch"/>
        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
        <Setter Property="VerticalContentAlignment" Value="Stretch"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <Border x:Name="Bd" SnapsToDevicePixels="True" Background="{TemplateBinding Background}">
                        <ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}"/>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsPressed" Value="True">
                            <Setter Property="Background" TargetName="Bd" Value="#FF98B5E2"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="ToolBarSplitButtonStyle" TargetType="{x:Type cc:SplitButton}">
        <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
        <Setter Property="BorderThickness" Value="1,1,1,1"/>
        <Setter Property="Background" Value="#00FFFFFF"/>
        <Setter Property="BorderBrush" Value="#00FFFFFF"/>
        <Setter Property="HorizontalAlignment" Value="Stretch"/>
        <Setter Property="VerticalAlignment" Value="Stretch"/>
        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
        <Setter Property="VerticalContentAlignment" Value="Stretch"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type cc:SplitButton}">
                    <Border SnapsToDevicePixels="True" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
                        <StackPanel Orientation="Horizontal">
                            <Button x:Name="PART_Button" Style="{DynamicResource ButtonStyle}" IsEnabled="{TemplateBinding IsMainButtonEnabled}">
                                <StackPanel Orientation="Horizontal">
                                    <Image Margin="2,2,2,2" VerticalAlignment="Center" Width="16" Height="16" Source="{TemplateBinding Image}"/>
                                    <Label Content="{TemplateBinding Text}" Target="{TemplateBinding Target}" VerticalAlignment="Center" Padding="0" Margin="3,0,3,0"/>
                                </StackPanel>
                            </Button>
                            <Border x:Name="line" Visibility="Hidden" BorderThickness="1,0,0,0" BorderBrush="{TemplateBinding BorderBrush}" />
                            <Path Fill="{DynamicResource GlyphBrush}" Data="M 0 0 L 4 4 L 8 0 Z"  Height="5" Margin="2,2,2,0"/>
                        </StackPanel>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsChecked" Value="True">
                            <Setter Property="BorderBrush" Value="#FF316AC5"/>
                            <Setter Property="Background" Value="#FFE1E6E8"/>
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="BorderBrush" Value="#FF316AC5"/>
                            <Setter Property="Background" Value="#FFE1E6E8"/>
                            <Setter Property="Visibility" Value="Visible" TargetName="line"/>
                        </Trigger>
                        <Trigger Property="IsKeyboardFocused" Value="True">
                            <Setter Property="BorderBrush" Value="#FF316AC5"/>
                            <Setter Property="Background" Value="#FFC1D2EE"/>
                            <Setter Property="Visibility" Value="Visible" TargetName="line"/>
                        </Trigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsMouseOver" Value="True"/>
                                <Condition Property="IsChecked" Value="True"/>
                            </MultiTrigger.Conditions>
                            <Setter Property="BorderBrush" Value="#FF4B4B6F"/>
                            <Setter Property="Background" Value="#FF98B5E2"/>
                            <Setter Property="Visibility" Value="Visible" TargetName="line"/>
                        </MultiTrigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsKeyboardFocused" Value="True"/>
                                <Condition Property="IsChecked" Value="True"/>
                            </MultiTrigger.Conditions>
                            <Setter Property="BorderBrush" Value="#FF4B4B6F"/>
                            <Setter Property="Background" Value="#FF98B5E2"/>
                            <Setter Property="Visibility" Value="Visible" TargetName="line"/>
                        </MultiTrigger>
                        <Trigger Property="IsPressed" Value="True">
                            <Setter Property="BorderBrush" Value="#FF4B4B6F"/>
                            <Setter Property="Background" Value="#FF98B5E2"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="ToolBarSplitRadioButtonStyle" TargetType="{x:Type cc:SplitRadioButton}">
        <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
        <Setter Property="BorderThickness" Value="1,1,1,1"/>
        <Setter Property="Background" Value="#00FFFFFF"/>
        <Setter Property="BorderBrush" Value="#00FFFFFF"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type cc:SplitRadioButton}">
                    <Border SnapsToDevicePixels="True" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="Auto"/>
                            </Grid.ColumnDefinitions>
                            <Button Grid.Column="0" x:Name="PART_Button" Style="{DynamicResource ButtonStyle}">
                                <Label Content="{TemplateBinding Text}" Target="{TemplateBinding Target}"
                                       HorizontalAlignment="Center" VerticalAlignment="Center" Padding="0" Margin="3,0,3,0"/>
                            </Button>
                            <Border Grid.Column="1" x:Name="line" Visibility="Hidden" BorderThickness="1,0,0,0" BorderBrush="{TemplateBinding BorderBrush}" />
                            <Path Grid.Column="2" Fill="{DynamicResource GlyphBrush}" Data="M 0 0 L 4 4 L 8 0 Z" VerticalAlignment="Center" Height="5" Margin="4,2,4,0"/>
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsChecked" Value="True">
                            <Setter Property="BorderBrush" Value="#FF316AC5"/>
                            <Setter Property="Background" Value="#FFEEEFFF"/>
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="BorderBrush" Value="#FF316AC5"/>
                            <Setter Property="Background" Value="#FF99CCFF"/>
                            <Setter Property="Visibility" Value="Visible" TargetName="line"/>
                        </Trigger>
                        <Trigger Property="IsKeyboardFocused" Value="True">
                            <Setter Property="BorderBrush" Value="#FF316AC5"/>
                            <Setter Property="Background" Value="#FFC1D2EE"/>
                            <Setter Property="Visibility" Value="Visible" TargetName="line"/>
                        </Trigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsMouseOver" Value="True"/>
                                <Condition Property="IsChecked" Value="True"/>
                            </MultiTrigger.Conditions>
                            <Setter Property="BorderBrush" Value="#FF4B4B6F"/>
                            <Setter Property="Background" Value="#FF98B5E2"/>
                            <Setter Property="Visibility" Value="Visible" TargetName="line"/>
                        </MultiTrigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsKeyboardFocused" Value="True"/>
                                <Condition Property="IsChecked" Value="True"/>
                            </MultiTrigger.Conditions>
                            <Setter Property="BorderBrush" Value="#FF4B4B6F"/>
                            <Setter Property="Background" Value="#FF98B5E2"/>
                            <Setter Property="Visibility" Value="Visible" TargetName="line"/>
                        </MultiTrigger>
                        <Trigger Property="IsPressed" Value="True">
                            <Setter Property="BorderBrush" Value="#FF4B4B6F"/>
                            <Setter Property="Background" Value="#FF98B5E2"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <DataTemplate x:Key="SplitMenuIconStyle">
        <Image Source="{Binding XPath=.}"></Image>
    </DataTemplate>

    <ControlTemplate x:Key="SplitMenuItemTemplate" TargetType="MenuItem">
        <Border Name="Border">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" SharedSizeGroup="Icon"/>
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="Auto" SharedSizeGroup="Shortcut"/>
                    <ColumnDefinition Width="13"/>
                </Grid.ColumnDefinitions>
                <ContentPresenter x:Name="Icon"
                          ContentTemplate="{StaticResource SplitMenuIconStyle}"
                          Margin="6,0,6,0"
                          VerticalAlignment="Center"
                          ContentSource="Icon"
                          Height="16" Width="16"/>
                <Border x:Name="Check"
                Width="13" Height="13"
                Visibility="Collapsed"
                Margin="6,0,6,0"
                Background="{StaticResource NormalBrush}"
                BorderThickness="1"
                BorderBrush="{StaticResource NormalBorderBrush}">
                    <Path x:Name="CheckMark"
                Width="7" Height="7"
                Visibility="Hidden"
                SnapsToDevicePixels="False"
                Stroke="{StaticResource GlyphBrush}"
                StrokeThickness="2"
                Data="M 0 0 L 7 7 M 0 7 L 7 0" />
                </Border>
                <ContentPresenter x:Name="HeaderHost"
                          Grid.Column="1"
                          ContentSource="Header"
                          RecognizesAccessKey="True"
                          Margin="5,2,0,2"
                          VerticalAlignment="Center"/>
                <TextBlock x:Name="InputGestureText"
                   Grid.Column="2"
                   Text="{TemplateBinding InputGestureText}"
                   Margin="5,2,0,2"
                   DockPanel.Dock="Right" />
            </Grid>
        </Border>
        <ControlTemplate.Triggers>
            <Trigger Property="Icon" Value="{x:Null}">
                <Setter TargetName="Icon" Property="Visibility" Value="Hidden"/>
            </Trigger>
            <Trigger Property="IsChecked" Value="true">
                <Setter TargetName="CheckMark" Property="Visibility" Value="Visible"/>
            </Trigger>
            <Trigger Property="IsCheckable" Value="true">
                <Setter TargetName="Check" Property="Visibility" Value="Visible"/>
                <Setter TargetName="Icon" Property="Visibility" Value="Hidden"/>
            </Trigger>
            <Trigger Property="IsHighlighted" Value="true">
                <Setter TargetName="Border" Property="Background" Value="{StaticResource SelectedBackgroundBrush}"/>
            </Trigger>
            <Trigger Property="IsEnabled" Value="false">
                <Setter Property="Foreground" Value="{StaticResource DisabledForegroundBrush}"/>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>
    
    
    <!-- ********************************************* TreeListView ******************************************************* -->



    <cc:LevelToIndentConverter x:Key="LevelToIndentConverter"/>

    <Style TargetType="{x:Type cc:TreeListViewItem}">

        <Setter Property="Panel.Background">
            <Setter.Value>
                <SolidColorBrush>#00FFFFFF</SolidColorBrush>
            </Setter.Value>
        </Setter>
        <Setter Property="Control.HorizontalContentAlignment">
            <Setter.Value>
                <Binding Path="HorizontalContentAlignment" RelativeSource="{RelativeSource AncestorLevel=1, Mode=FindAncestor, AncestorType=ItemsControl}" />
            </Setter.Value>
        </Setter>
        <Setter Property="Control.VerticalContentAlignment">
            <Setter.Value>
                <Binding Path="VerticalContentAlignment" RelativeSource="{RelativeSource AncestorLevel=1, Mode=FindAncestor, AncestorType=ItemsControl}" />
            </Setter.Value>
        </Setter>
        <Setter Property="Control.Padding">
            <Setter.Value>
                <Thickness>1,0,0,0</Thickness>
            </Setter.Value>
        </Setter>
        <Setter Property="TextElement.Foreground">
            <Setter.Value>
                <DynamicResource ResourceKey="{x:Static SystemColors.ControlTextBrushKey}" />
            </Setter.Value>
        </Setter>
        <Setter Property="FrameworkElement.FocusVisualStyle">
            <Setter.Value>
                <Style TargetType="IFrameworkInputElement">
                    <Style.Resources>
                        <ResourceDictionary />
                    </Style.Resources>
                    <Setter Property="Control.Template">
                        <Setter.Value>
                            <ControlTemplate>
                                <Rectangle />
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </Setter.Value>
        </Setter>
        <Setter Property="Control.Template">
            <Setter.Value>
                <ControlTemplate TargetType="cc:TreeListViewItem">
                    <StackPanel>
                        <Border BorderBrush="{TemplateBinding Border.BorderBrush}" BorderThickness="{TemplateBinding Border.BorderThickness}" Name="Bd" Background="{TemplateBinding Panel.Background}" SnapsToDevicePixels="True" Padding="{TemplateBinding Control.Padding}">
                            <cc:TreeGridViewRowPresenter x:Name="PART_Header"
                FirstColumnIndent="{Binding Level,Converter={StaticResource LevelToIndentConverter},RelativeSource={RelativeSource AncestorType={x:Type cc:TreeListViewItem}},ConverterParameter=19}"
                Content="{TemplateBinding Header}" 
                Columns="{Binding Path=Columns,RelativeSource={RelativeSource AncestorType={x:Type cc:TreeListView}}}">
                                <cc:TreeGridViewRowPresenter.Expander>
                                    <Grid>
                                        <ToggleButton Width="19" Height="16" ClickMode="Press" Name="Expander"
                                                  IsChecked="{Binding Path=IsExpanded,RelativeSource={RelativeSource AncestorType={x:Type cc:TreeListViewItem}}}">
                                            <ToggleButton.Style>
                                                <Style TargetType="ToggleButton">
                                                    <Style.Resources>
                                                        <ResourceDictionary />
                                                    </Style.Resources>
                                                    <Setter Property="UIElement.Focusable">
                                                        <Setter.Value>
                                                            <s:Boolean>False</s:Boolean>
                                                        </Setter.Value>
                                                    </Setter>
                                                    <Setter Property="FrameworkElement.Width">
                                                        <Setter.Value>
                                                            <s:Double>19</s:Double>
                                                        </Setter.Value>
                                                    </Setter>
                                                    <Setter Property="FrameworkElement.Height">
                                                        <Setter.Value>
                                                            <s:Double>13</s:Double>
                                                        </Setter.Value>
                                                    </Setter>
                                                    <Setter Property="Control.Template">
                                                        <Setter.Value>
                                                            <ControlTemplate TargetType="ToggleButton">
                                                                <Grid Width="15" Height="13" Background="Transparent">
                                                                    <Path Margin="1,1,1,1"
                                                                          Data="M 4 0 L 8 4 L 4 8 Z"
                                                                          Fill="{DynamicResource {x:Static SystemColors.WindowTextBrushKey}}"
                                                                          Name="ExpandPath" />
                                                                </Grid>
                                                                <ControlTemplate.Triggers>
                                                                    <Trigger Property="ToggleButton.IsChecked">
                                                                        <Setter Property="Path.Data" TargetName="ExpandPath">
                                                                            <Setter.Value>
                                                                                <StreamGeometry>M 0 4 L 8 4 L 4 8 Z</StreamGeometry>
                                                                            </Setter.Value>
                                                                        </Setter>
                                                                        <Trigger.Value>
                                                                            <s:Boolean>True</s:Boolean>
                                                                        </Trigger.Value>
                                                                    </Trigger>
                                                                </ControlTemplate.Triggers>
                                                            </ControlTemplate>
                                                        </Setter.Value>
                                                    </Setter>
                                                </Style>
                                            </ToggleButton.Style>
                                        </ToggleButton>
                                    </Grid>
                                </cc:TreeGridViewRowPresenter.Expander>
                            </cc:TreeGridViewRowPresenter>
                        </Border>

                        <ItemsPresenter Name="ItemsHost" />
                    </StackPanel>
                    <ControlTemplate.Triggers>
                        <Trigger Property="TreeViewItem.IsExpanded">
                            <Setter Property="UIElement.Visibility" TargetName="ItemsHost" Value="{x:Static Visibility.Collapsed}" />
                            <Trigger.Value>
                                <s:Boolean>False</s:Boolean>
                            </Trigger.Value>
                        </Trigger>
                        <Trigger Property="ItemsControl.HasItems">
                            <Setter Property="UIElement.Visibility" TargetName="Expander" Value="{x:Static Visibility.Hidden}" />
                            <Trigger.Value>
                                <s:Boolean>False</s:Boolean>
                            </Trigger.Value>
                        </Trigger>
                        <Trigger Property="TreeViewItem.IsSelected">
                            <Setter Property="Panel.Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}" />
                            <Setter Property="TextElement.Foreground">
                                <Setter.Value>
                                    <DynamicResource ResourceKey="{x:Static SystemColors.HighlightTextBrushKey}" />
                                </Setter.Value>
                            </Setter>
                            <Trigger.Value>
                                <s:Boolean>True</s:Boolean>
                            </Trigger.Value>
                        </Trigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="TreeViewItem.IsSelected">
                                    <Condition.Value>
                                        <s:Boolean>True</s:Boolean>
                                    </Condition.Value>
                                </Condition>
                                <Condition Property="TreeViewItem.IsSelectionActive">
                                    <Condition.Value>
                                        <s:Boolean>False</s:Boolean>
                                    </Condition.Value>
                                </Condition>
                            </MultiTrigger.Conditions>
                            <Setter Property="Panel.Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" />
                            <Setter Property="TextElement.Foreground">
                                <Setter.Value>
                                    <DynamicResource ResourceKey="{x:Static SystemColors.ControlTextBrushKey}" />
                                </Setter.Value>
                            </Setter>
                        </MultiTrigger>
                        <Trigger Property="UIElement.IsEnabled">
                            <Setter Property="TextElement.Foreground">
                                <Setter.Value>
                                    <DynamicResource ResourceKey="{x:Static SystemColors.GrayTextBrushKey}" />
                                </Setter.Value>
                            </Setter>
                            <Trigger.Value>
                                <s:Boolean>False</s:Boolean>
                            </Trigger.Value>
                        </Trigger>
                    </ControlTemplate.Triggers>

                </ControlTemplate>
            </Setter.Value>
        </Setter>

    </Style>

    <Style x:Key="scroll">
        <Setter Property="UIElement.Focusable">
            <Setter.Value>
                <s:Boolean>False</s:Boolean>
            </Setter.Value>
        </Setter>
        <Setter Property="Control.Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ScrollViewer}">
                    <Grid Background="{TemplateBinding Background}"
                SnapsToDevicePixels="true">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="Auto"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*"/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>
                        <DockPanel Margin="{TemplateBinding Padding}">
                            <ScrollViewer DockPanel.Dock="Top"
                            HorizontalScrollBarVisibility="Hidden"
                            VerticalScrollBarVisibility="Hidden"
                            Focusable="false">
                                <GridViewHeaderRowPresenter Columns="{Binding Path=Columns,RelativeSource={RelativeSource AncestorType={x:Type cc:TreeListView}}}"
                                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                            </ScrollViewer>
                            <ScrollContentPresenter Name="PART_ScrollContentPresenter"
                                      KeyboardNavigation.DirectionalNavigation="Local"
                                      Content="{TemplateBinding Content}"
                                      ContentTemplate="{TemplateBinding ContentTemplate}"
                                      CanContentScroll="{TemplateBinding CanContentScroll}"
                                      SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                        </DockPanel>
                        <ScrollBar Name="PART_HorizontalScrollBar"
                       Orientation="Horizontal"
                       Grid.Row="1"
                       Minimum="0.0"
                       Maximum="{TemplateBinding ScrollableWidth}"
                       ViewportSize="{TemplateBinding ViewportWidth}"
                       Value="{Binding Path=HorizontalOffset,RelativeSource={RelativeSource TemplatedParent},Mode=OneWay}"
                       Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"
                       Cursor="Arrow"/>
                        <ScrollBar Name="PART_VerticalScrollBar"
                       Orientation="Vertical"
                       Grid.Column="1"
                       Minimum="0.0"
                       Maximum="{TemplateBinding ScrollableHeight}"
                       ViewportSize="{TemplateBinding ViewportHeight}"
                       Value="{Binding Path=VerticalOffset,RelativeSource={RelativeSource TemplatedParent},Mode=OneWay}"
                       Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"
                       Cursor="Arrow"/>
                        <DockPanel Grid.Column="1"
                       Grid.Row="1"
                       Background="{Binding Path=Background,ElementName=PART_VerticalScrollBar}"
                       LastChildFill="false">
                            <Rectangle DockPanel.Dock="Left"
                         Width="1"
                         Fill="White"
                         Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"/>
                            <Rectangle DockPanel.Dock="Top"
                         Height="1"
                         Fill="White"
                         Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"/>
                        </DockPanel>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type cc:TreeListView}">
        <Setter Property="Panel.Background">
            <Setter.Value>
                <DynamicResource ResourceKey="{x:Static SystemColors.WindowBrushKey}" />
            </Setter.Value>
        </Setter>
        <Setter Property="Border.BorderBrush">
            <Setter.Value>
                <SolidColorBrush>#00FFFFFF</SolidColorBrush>
            </Setter.Value>
        </Setter>
        <Setter Property="Border.BorderThickness">
            <Setter.Value>
                <Thickness>2,2,2,2</Thickness>
            </Setter.Value>
        </Setter>
        <Setter Property="TextElement.Foreground">
            <Setter.Value>
                <DynamicResource ResourceKey="{x:Static SystemColors.WindowTextBrushKey}" />
            </Setter.Value>
        </Setter>
        <Setter Property="ScrollViewer.HorizontalScrollBarVisibility">
            <Setter.Value>
                <x:Static Member="ScrollBarVisibility.Auto" />
            </Setter.Value>
        </Setter>
        <Setter Property="ScrollViewer.VerticalScrollBarVisibility">
            <Setter.Value>
                <x:Static Member="ScrollBarVisibility.Auto" />
            </Setter.Value>
        </Setter>
        <Setter Property="ScrollViewer.CanContentScroll">
            <Setter.Value>
                <s:Boolean>True</s:Boolean>
            </Setter.Value>
        </Setter>
        <Setter Property="Control.Template">
            <Setter.Value>

                <ControlTemplate TargetType="cc:TreeListView">
                    <wpfc:ClassicBorderDecorator BorderBrush="{TemplateBinding Border.BorderBrush}" BorderStyle="Sunken" BorderThickness="{TemplateBinding Border.BorderThickness}" Name="Bd" Background="{TemplateBinding Panel.Background}" SnapsToDevicePixels="True">

                        <ScrollViewer Style="{StaticResource scroll}" Background="{TemplateBinding Background}"
                          Focusable="false"
                          CanContentScroll="false"
                          HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"
                          VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}"
                          Padding="{TemplateBinding Padding}"
                          SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
                            <ItemsPresenter SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" />
                        </ScrollViewer>

                    </wpfc:ClassicBorderDecorator>

                    <ControlTemplate.Triggers>
                        <Trigger Property="UIElement.IsEnabled">
                            <Setter Property="Panel.Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" />
                            <Trigger.Value>
                                <s:Boolean>False</s:Boolean>
                            </Trigger.Value>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>

    </Style>



    <!--  ******************************************** Expander **************************************************** -->

    <Style x:Key="foo" TargetType="{x:Type Expander}">
        <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
        <Setter Property="Padding" Value="2"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="BorderBrush" Value="{StaticResource TabControlNormalBorderBrush}"/>
        <Setter Property="Background" Value="#FFFFFF"/>
    </Style>

    <LinearGradientBrush x:Key="NormalGradientBrush" StartPoint="0,0" EndPoint="0,1">
        <GradientBrush.GradientStops>
            <GradientStopCollection>
                <GradientStop Color="#FFF" Offset="0.975"/>
                <GradientStop Color="#FFE0E9F0" Offset="1.0"/>
            </GradientStopCollection>
        </GradientBrush.GradientStops>
    </LinearGradientBrush>

    <Style x:Key="ExpanderHeaderFocusVisual">
        <Setter Property="Control.Template">
            <Setter.Value>
                <ControlTemplate>
                    <Border>
                        <Rectangle Stroke="Black" StrokeDashArray="1 2" StrokeThickness="1" Margin="0" SnapsToDevicePixels="true"/>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="ExpanderDownHeaderStyle" TargetType="{x:Type ToggleButton}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToggleButton}">
                    <Border Padding="2" CornerRadius="1"
                            Background="#ffE0E9F0" BorderBrush="#ff455973" BorderThickness=".75" Margin="-.75">
                        <Grid SnapsToDevicePixels="False" Background="Transparent">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="15"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>
                            <Ellipse x:Name="circle" Stroke="DarkGray" HorizontalAlignment="Center" VerticalAlignment="Center" Width="15" Height="15"/>
                            <Path x:Name="arrow" Stroke="#777" StrokeThickness="2" HorizontalAlignment="Center" VerticalAlignment="Center" SnapsToDevicePixels="false" Data="M 1,1.5 L 4.5,5 L 8,1.5"/>
                            <ContentPresenter HorizontalAlignment="Left" Margin="4,0,0,0"
                                              VerticalAlignment="Center" SnapsToDevicePixels="True" Grid.Column="1" RecognizesAccessKey="True"/>
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsChecked" Value="true">
                            <Setter Property="Data" TargetName="arrow" Value="M 1,4.5  L 4.5,1  L 8,4.5"/>
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="true">
                            <Setter Property="Stroke" TargetName="circle" Value="#FF3C7FB1"/>
                            <Setter Property="Stroke" TargetName="arrow" Value="#222"/>
                        </Trigger>
                        <Trigger Property="IsPressed" Value="true">
                            <Setter Property="Stroke" TargetName="circle" Value="#FF526C7B"/>
                            <Setter Property="StrokeThickness" TargetName="circle" Value="1.5"/>
                            <Setter Property="Stroke" TargetName="arrow" Value="#FF003366"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style TargetType="{x:Type Expander}">
        <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
        <Setter Property="VerticalContentAlignment" Value="Stretch"/>
        <Setter Property="BorderThickness" Value="1"/>

        <Setter Property="BorderBrush" Value="#FF455973"/><!--D5DFE5-->
        <Setter Property="Background" Value="#FFFFFF"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Expander}">
                    <Border SnapsToDevicePixels="False" Background="{StaticResource NormalGradientBrush}"
                            BorderBrush="#ff455973" BorderThickness=".75" CornerRadius="1">
                        <DockPanel>
                            <ToggleButton x:Name="HeaderSite" FocusVisualStyle="{StaticResource ExpanderHeaderFocusVisual}"
                                          Margin="0" MinHeight="0" MinWidth="0" Style="{StaticResource ExpanderDownHeaderStyle}"
                                          Content="{TemplateBinding Header}" ContentTemplate="{TemplateBinding HeaderTemplate}"
                                          ContentTemplateSelector="{TemplateBinding HeaderTemplateSelector}"
                                          FontFamily="{TemplateBinding FontFamily}" FontSize="{TemplateBinding FontSize}" FontStretch="{TemplateBinding FontStretch}" FontStyle="{TemplateBinding FontStyle}" FontWeight="{TemplateBinding FontWeight}" Foreground="{TemplateBinding Foreground}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" Padding="{TemplateBinding Padding}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" IsChecked="{Binding IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" DockPanel.Dock="Top"/>
                            <ContentPresenter x:Name="ExpandSite"
                                                  Margin="{TemplateBinding Padding}"
                                                  HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                                  VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                                  Focusable="false" Visibility="Collapsed" DockPanel.Dock="Bottom"/>
                        </DockPanel>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsExpanded" Value="true">
                            <Setter Property="Visibility" TargetName="ExpandSite" Value="Visible"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>


    <BorderGapMaskConverter x:Key="BorderGapMaskConverter"/>

    <Style x:Key="GroupBoxStyle" TargetType="{x:Type Expander}">
        <Setter Property="BorderBrush" Value="#D5DFE5"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Expander}">
                    <Grid SnapsToDevicePixels="true">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="6"/>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="6"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="*"/>
                            <RowDefinition Height="6"/>
                        </Grid.RowDefinitions>

                        <Border BorderBrush="Transparent" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}"
									Grid.ColumnSpan="4" Grid.Column="0" CornerRadius="4" Grid.Row="1" Grid.RowSpan="3"/>

                        <ContentPresenter x:Name="ExpandSite" Grid.ColumnSpan="2" Grid.Column="1" Margin="{TemplateBinding Padding}" Grid.Row="2"
											   Focusable="false" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
											   Visibility="Collapsed" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
											   SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>

                        <Border BorderBrush="White" BorderThickness="{TemplateBinding BorderThickness}" Grid.ColumnSpan="4" CornerRadius="4" Grid.Row="1" Grid.RowSpan="3">
                            <Border.OpacityMask>
                                <MultiBinding ConverterParameter="7" Converter="{StaticResource BorderGapMaskConverter}">
                                    <Binding ElementName="HeaderSite" Path="ActualWidth"/>
                                    <Binding Path="ActualWidth" RelativeSource="{RelativeSource Self}"/>
                                    <Binding Path="ActualHeight" RelativeSource="{RelativeSource Self}"/>
                                </MultiBinding>
                            </Border.OpacityMask>
                            <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="3">
                                <Border BorderBrush="White" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="2"/>
                            </Border>
                        </Border>

                        <ToggleButton IsChecked="{Binding IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
                                          FocusVisualStyle="{StaticResource ExpanderHeaderFocusVisual}" Cursor="Hand"
										  x:Name="HeaderSite" Grid.Column="1" Padding="3,1,3,0" Grid.Row="0" Grid.RowSpan="2"
										  Content="{Binding Path=Header, RelativeSource={RelativeSource TemplatedParent}}">
                            <ToggleButton.Template>
                                <ControlTemplate TargetType="{x:Type ToggleButton}">
                                    <StackPanel Orientation="Horizontal">
                                        <Path x:Name="arrow" Data="M 1,1.5 L 4.5,5 L 8,1.5" HorizontalAlignment="Center" SnapsToDevicePixels="false" Stroke="#777"
														StrokeThickness="2" VerticalAlignment="Center" Margin="1,0,2,0"/>
                                        <ContentPresenter Content="{Binding Path=Content, RelativeSource={RelativeSource TemplatedParent}}"
																RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                                    </StackPanel>
                                    <ControlTemplate.Triggers>
                                        <Trigger Property="IsChecked" Value="true">
                                            <Setter Property="Data" TargetName="arrow" Value="M 1,4.5  L 4.5,1  L 8,4.5"/>
                                        </Trigger>
                                    </ControlTemplate.Triggers>
                                </ControlTemplate>
                            </ToggleButton.Template>
                        </ToggleButton>

                    </Grid>

                    <ControlTemplate.Triggers>
                        <Trigger Property="IsExpanded" Value="true">
                            <Setter Property="Visibility" TargetName="ExpandSite" Value="Visible"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

<!--// borderless window-->

    <LinearGradientBrush x:Key="SysTitleBrush" StartPoint="0.5,0" EndPoint="0.5,1">
        <GradientStop Color="#ff373737" Offset="0.0" />
        <GradientStop Color="#ff565656" Offset="0.5" />
        <GradientStop Color="#ff565656" Offset="1" />
    </LinearGradientBrush>
    <LinearGradientBrush x:Key="SysHoverBrushX" StartPoint="0.5,0" EndPoint="0.5,1">
        <GradientStop Color="#ffdf0000" Offset="0.0" />
        <GradientStop Color="#ff8b0000" Offset="0.75" />
        <GradientStop Color="#ffdf0000" Offset="1" />
    </LinearGradientBrush>
    <LinearGradientBrush x:Key="SysPressedBrush" StartPoint="0.5,0" EndPoint="0.5,1">
        <GradientStop Color="#ff373737" Offset="0.0" />
        <GradientStop Color="#ff898989" Offset="0.25" />
        <GradientStop Color="#ff373737" Offset="1" />
    </LinearGradientBrush>
    <LinearGradientBrush x:Key="SysHoverBrush" StartPoint="0.5,0" EndPoint="0.5,1">
        <GradientStop Color="#ff60B2D1" Offset="0.0" />
        <GradientStop Color="#ff2B526A" Offset="0.75" />
        <GradientStop Color="#ff60B2D1" Offset="1" />
    </LinearGradientBrush>
    <SolidColorBrush x:Key="MenuButtonDisabledBrush" Color="#ff87CEEB" />

    <Style TargetType="splx:SplxBorderButton" x:Key="SysButton">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="splx:SplxBorderButton">
                    <Border x:Name="Border" BorderBrush="DimGray" BorderThickness="1"
                                CornerRadius="{TemplateBinding splx:SplxBorderButton.CornerRadius}">
                        <ContentPresenter Content="{TemplateBinding Button.Content}"
                                VerticalAlignment="Center" HorizontalAlignment="Center" />
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsKeyboardFocused" Value="true">
                            <Setter TargetName="Border" Property="Background" Value="{StaticResource SysHoverBrush}"/>
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="true">
                            <Setter TargetName="Border" Property="Background" Value="{StaticResource SysHoverBrush}"/>
                        </Trigger>
                        <Trigger Property="IsPressed" Value="true">
                            <Setter TargetName="Border" Property="Background" Value="{StaticResource SysPressedBrush}"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter TargetName="Border" Property="Background" Value="{StaticResource MenuButtonDisabledBrush}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style TargetType="splx:SplxBorderButton" x:Key="SysButtonX">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="splx:SplxBorderButton">
                    <Border x:Name="Border" BorderBrush="DimGray" BorderThickness="1"
                                CornerRadius="{TemplateBinding splx:SplxBorderButton.CornerRadius}">
                        <ContentPresenter Content="{TemplateBinding Button.Content}"
                                VerticalAlignment="Center" HorizontalAlignment="Center" />
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsKeyboardFocused" Value="true">
                            <Setter TargetName="Border" Property="Background" Value="{StaticResource SysHoverBrushX}"/>
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="true">
                            <Setter TargetName="Border" Property="Background" Value="{StaticResource SysHoverBrushX}"/>
                        </Trigger>
                        <Trigger Property="IsPressed" Value="true">
                            <Setter TargetName="Border" Property="Background" Value="{StaticResource SysPressedBrush}"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter TargetName="Border" Property="Background" Value="{StaticResource MenuButtonDisabledBrush}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>


</ResourceDictionary>